package com.dataart.training.crimequalification.beans;

import com.dataart.training.crimequalification.facesutils.ResourceBundleManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.faces.bean.ManagedBean;
import java.io.Serializable;
import java.util.ResourceBundle;

/**
 * JSF managed bean responsible for handling tasks involving password validation.
 */
@ManagedBean
@Component
@Scope(value = "request")
public class PasswordValidationBean implements Serializable {

    //----------------------------------------------------------------

    private static final Logger logger = LoggerFactory
            .getLogger(PasswordValidationBean.class);

    //----------------------------------------------------------------

    private static final String BUNDLE_NAME = "conf";
    private static final String REGEX_PATTERN_KEY = "valid.regexpswpattern";

    //----------------------------------------------------------------

    public String getPasswordValidationPattern() {
        ResourceBundleManager mgr = new ResourceBundleManager();
        ResourceBundle bundle = mgr.getResourceBundleByName(BUNDLE_NAME);
        return mgr.getValueFromBundleByKey(bundle, REGEX_PATTERN_KEY);
    }

}
